home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1993 September
/
clonecd
/
September 93.img
/
Archives
/
Fun, Tricks & Hacks
/
Ümlåût Õmêléttè
/
ü.c
< prev
next >
Wrap
Text File
|
1992-05-13
|
797b
|
35 lines
#define ACTIVE "aeiouACEOU"
#define TRANSLATE "a6åàäâãá e4èéêë i4ìîíï o6øöôòóõ u4ùúûü A4ÅÀÄÃ C1Ç E1É O2ÖÕ U1Ü "
void
Umlaut(register char *buffer,int len)
{ char *table = TRANSLATE, *active = ACTIVE;
register char *tp;
register int i,j,v,count;
v = 0;
for (i = 0; i < len; i++)
{ // Update the random number // Rotate left by one & xor in char
if (v < 0)
v = ((v << 1) ^ buffer[i]) + 1;
else
v = ((v << 1) ^ buffer[i]);
// Find if this is an active character
for (j = 0; j < sizeof(ACTIVE) - 1; j++)
if (active[j] == buffer[i])
break;
if (j < sizeof(ACTIVE) - 1) // Done right
{ tp = table;
while (*tp != buffer[i])
{ while (*tp != ' ')
tp++;
tp++;
}
count = tp[1] - '0';
buffer[i] = tp[2+((v & 0x7FFFFFFF)%count)];
}
}
}